/*
* Copyright© 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package com.laihuichuxing.netty.server.server.module.netcar;

import com.google.protobuf.InvalidProtocolBufferException;
import com.laihuichuxing.netty.common.core.session.Session;
import com.laihuichuxing.netty.common.core.session.SessionManager;
import com.laihuichuxing.protobuf.module.UserModule;
import com.laihuichuxing.socket.ModuleId;
import com.laihuichuxing.socket.NetCarCmd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * Description: 曹操状态通知
 *
 * @author YangGuang
 * @since: 1.0
 * Create Date Time: 2018/10/18 16:14
 * Update Date Time:
 */
@Component
public class NetCarHandlerImpl implements NetCarHandler {

    private Logger logger = LoggerFactory.getLogger(NetCarHandlerImpl.class);

    @Override
    public void caocaoNotify(Session session, byte[] data) {
        try {
            // 反序列化数据
            UserModule.Notify notify = UserModule.Notify.parseFrom(data);
            // 发送消息给乘客端
            SessionManager.sendMessage(notify.getMobile(), ModuleId.STROKE, NetCarCmd.CAOCAO_NOTIFY, notify);
        } catch (InvalidProtocolBufferException e) {
            logger.error("曹操响应乘客:{}", e.toString(), e);
        }
    }
}
